﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace WinCourseControls
{
    public partial class FrmPictureBox : Form
    {
        public FrmPictureBox()
        {
            InitializeComponent();
        }

        /// <summary>
        /// 加载按钮-加载指定图片
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnLoad_Click(object sender, EventArgs e)
        {
            // 第一种方式
            // 绝对路径赋值
            //pbImg02.Image = Image.FromFile(@"D:\工作\基础班Vip03\Winform控件录制合集新\控件命令新2\合集代码项目\WinCourseControls\WinCourseControls\Resources\logbg.jpg");
            // 相对路径方式赋值-需要设置图片始终复制
            //  pbImg02.Image = Image.FromFile(@"Resources\logbg.jpg");

            // 方式二
            //ImageLocation  指定图片的路径-绝对路径方式赋值
            //pbImg02.ImageLocation = @"D:\工作\基础班Vip03\Winform控件录制合集新\控件命令新2\合集代码项目\WinCourseControls\WinCourseControls\Resources\logbg.jpg";
            pbImg02.ImageLocation = @"Resources\logbg.jpg";
            // 设置图片显示效果-模式
            pbImg02.SizeMode = PictureBoxSizeMode.StretchImage;
        }

       /// <summary>
       /// 交换图片按钮
       /// </summary>
       /// <param name="sender"></param>
       /// <param name="e"></param>
        private void btnChange_Click(object sender, EventArgs e)
        {
            // 临时存放图片变量-算法a、b、c交换
            PictureBox pb = new PictureBox();
            pb.Image = picLeft.Image;
            picLeft.Image = picRight.Image;
            picRight.Image = pb.Image;
        }
    }
}
